<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>砸金蛋</title>
    <meta name="description" content="砸金蛋" />
    <meta http-equiv="pragma" content="no-store">
    <meta http-equiv="Cache-Control" content="no-cache,no-store">
    <meta http-equiv="expires" content="0">
    <meta name="format-detection" content="telephone=no"/>
    <meta name="wap-font-scale" content="no">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=jDh3pZvkeqUnuKmWZeyEZSuD0GgpoeSq"></script>
    <link rel="stylesheet" href="../common/css/modal-px.css?" media="screen" title="no_title" charset="utf-8">
    <link rel="stylesheet" href="../common/css/plugins.css" media="screen" title="no_title" charset="utf-8">
    <style media="screen" title="no_title">@charset "UTF-8";input{-webkit-appearance: none;}.clear:after{content:'';display:block;clear:both;width:0;height:0}body,ul,ol,li,p,h1,h2,h3,h4,h5,h6,form,fieldset,table,td,img,div{margin:0;padding:0;border:0}ul,ol{list-style-type:none}select,input,img,select{vertical-align:middle}*{margin:0;padding:0;-webkit-tap-highlight-color:rgba(255,255,255,0);font-family:PingFang SC,STHeiti,"Microsoft Yahei","微软雅黑",Helvetica,sans-serif;-webkit-touch-callout:none;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;-o-box-sizing:border-box;box-sizing:border-box;outline:0}a:active,a:hover,a:link,a:visited{text-decoration:none;outline:0}ul,li{list-style:none}html,body{width:100%;font-size:20px;background-color:#f0f0f0}@keyframes knock{0%{top:-1.5rem}50%{top:0}100%{top:-1.5rem}}@-webkit-keyframes knock{0%{top:-1.5rem}50%{top:0}100%{top:-1.5rem}}html,body{background-color:#fa664a;background:url(./img/golden-egg-bg-px.png) repeat;background-size:cover}.wrap{width:100%;min-height:100vh;background:url(./img/golden-egg-bg.png) no-repeat top center;background-size:100% auto;padding:10.75rem .45rem 1.5rem}.wrap .date{font-size:.65rem;color:#fff;text-align:center}.wrap .rule-btn{width:4.3rem;height:1.85rem;margin:1rem auto 0;background:url(./img/rule-btn.png) no-repeat center;background-size:contain;font-size:0;color:#fff;text-indent:-999px}.wrap .eggs{font-size:0;position:relative;-webkit-box-orient:horizontal;-ms-box-orient:horizontal;-moz-box-orient:horizontal;-webkit-flex-flow:row nowrap;-ms-flex-flow:row nowrap;-moz-flex-flow:row nowrap;flex-flow:row nowrap;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;-ms-justify-content:center;-webkit-justify-content:center;justify-content:center;-ms-justify:center;-webkit-justify:center;justify:center;-ms-box-align:flex-end;-webkit-box-align:end;box-align:flex-end;-ms-align-items:flex-end;-webkit-align-items:flex-end;align-items:flex-end}.wrap .eggs .egg{position:relative;width:5rem;height:5.775rem;margin-top:1.75rem;display:block;font-size:0;vertical-align:baseline;-webkit-box-flex:1;-moz-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}.wrap .eggs .egg.hammer:after{content:'';width:2.25rem;height:2.05rem;display:block;position:absolute;right:0;top:-1.25rem;background:url(./img/hammer.png) no-repeat center;background-size:contain;animation:knock .4s linear;-webkit-animation:knock .4s linear}.wrap .eggs .egg i{position:absolute;left:.45rem;top:0;display:block;width:4.1rem;height:100%;background:url(./img/all-egg1.png) no-repeat center;background-size:contain}.wrap .eggs .egg.half i{width:6rem}.wrap .eggs .egg:nth-child(1) i{background:url(./img/all-egg1.png) no-repeat center bottom;background-size:contain}.wrap .eggs .egg.half:nth-child(1) i{left:-.5rem;top:.55rem;background:url(./img/half-egg1.png) no-repeat center bottom;background-size:contain}.wrap .eggs .egg:nth-child(2) i{background:url(./img/all-egg2.png) no-repeat center bottom;background-size:contain}.wrap .eggs .egg.half:nth-child(2) i{left:-.5rem;top:.5rem;background:url(./img/half-egg2.png) no-repeat center bottom;background-size:contain}.wrap .eggs .egg:nth-child(3) i{background:url(./img/all-egg3.png) no-repeat center bottom;background-size:contain}.wrap .eggs .egg.half:nth-child(3) i{left:-.5rem;top:.5rem;background:url(./img/half-egg3.png) no-repeat center bottom;background-size:contain}.wrap .times{margin-top:.9rem;margin-bottom:1.5rem;text-align:center;font-size:.65rem;color:#fff}.wrap .times i{font-style:normal;color:#fed900}.wrap .winners{width:100%;position:relative;padding:.3rem;background:#960500;-webkit-border-radius:.2rem;-moz-border-radius:.2rem;-ms-border-radius:.2rem;-o-border-radius:.2rem;border-radius:.2rem}.wrap .winners .win-title{width:7.025rem;height:1.8rem;position:absolute;top:-.9rem;left:50%;margin-left:-3.5125rem;background:url(./img/winners-title.png) no-repeat center;background-size:contain}.wrap .winners ul{padding:.9rem .9rem .5rem;background:#870300}.wrap .winners ul li{color:#a96563;font-size:.6rem;padding:.3rem 0;-webkit-box-orient:horizontal;-ms-box-orient:horizontal;-moz-box-orient:horizontal;-webkit-flex-flow:row nowrap;-ms-flex-flow:row nowrap;-moz-flex-flow:row nowrap;flex-flow:row nowrap;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex}.wrap .winners ul li span{display:block}.wrap .winners ul li span:nth-child(2){-webkit-box-flex:1;-moz-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;text-align:right;margin-left:.25rem;color:#fed900;word-break:keep-all;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wrap .winners ul li i{color:#fff;font-style:normal}.wrap .my-prize{width:4.3rem;height:1.85rem;margin:1rem auto 0;background:url(./img/my-prize-btn.png) no-repeat center;background-size:contain;font-size:0;color:#fff;text-indent:-999px}.bombBox{width:100vw;height:100vh;position:fixed;top:0;right:0;bottom:0;left:0;background:rgba(0,0,0,.4);padding:0 1.75rem;display:none;z-index:100}.bombBox.show{display:block}.bombBox:after{content:'';display:block;clear:both;width:0;height:0}.bombBox .close{width:1.05rem;height:3.425rem;background:url(../common/img/red-close.png) no-repeat bottom center;background-size:100% auto;margin-bottom:1.25rem;float:right}.bombBox .boxContent{width:100%;background:#fff;-webkit-border-radius:.15rem;-moz-border-radius:.15rem;-ms-border-radius:.15rem;-o-border-radius:.15rem;border-radius:.15rem;float:right;padding:0 .975rem 1.35rem}.bombBox .boxContent h3{text-align:center;font-size:.8rem;font-weight:500;padding:.6rem 0}.bombBox .boxContent button{width:6.95rem;height:1.55rem;line-height:1.55rem;outline:0;display:block;background:#fb3131;color:#fff;font-size:.7rem;text-align:center;font-weight:500;margin:1.5rem auto 0;border:0;-webkit-border-radius:.15rem;-moz-border-radius:.15rem;-ms-border-radius:.15rem;-o-border-radius:.15rem;border-radius:.15rem}.bombBox .boxContent form input{border:1px solid #e5e5e5;display:block;font-size:.65rem;width:100%;height:1.55rem;margin-top:.6rem;padding:0 .5rem;outline:0;-webkit-border-radius:.15rem;-moz-border-radius:.15rem;-ms-border-radius:.15rem;-o-border-radius:.15rem;border-radius:.15rem}.bombBox.success .boxContent{height:12.5rem;background:url(../common/img/success-bg.png) no-repeat center;background-size:100% 100%}.bombBox.success .boxContent .prizeName{text-align:center;font-size:.7rem;color:#fff;margin-top:3rem}.bombBox.success .boxContent .imgs{margin-top:.85rem}.bombBox.success .boxContent .prizeImg{width:3rem;height:3rem;display:block;margin:0 auto;background-color:#fff;-webkit-border-radius:.15rem;-moz-border-radius:.15rem;-ms-border-radius:.15rem;-o-border-radius:.15rem;border-radius:.15rem}.bombBox.success .boxContent .sponsorImg{width:3rem;height:1.25rem;display:block;margin:0 auto;background-color:#fff;margin-top:.25rem}.bombBox.success .boxContent button{margin-top:.6rem}.bombBox.fail .boxContent{height:12.5rem;background:url(../common/img/fail-bg.png) no-repeat center;background-size:100% 100%}.bombBox.fail .boxContent button{margin-top:9rem}.bombBox.text .boxContent{font-size:.63rem;color:#000;line-height:1.6;padding-top:.975rem;}#main{display:none;}</style>
    <style>
        .bombBox.text .boxContent{
            max-height: 65vh;
            overflow: scroll;
        }
    </style>
</head>
<body style="visibility: hidden;">
<div class="wrap" id="main">
    <div class="date">活动时间：2017-05-23 00:00:00</div>
    <div class="rule-btn">活动规则</div>
    <div class="eggs">
        <span class="egg"><i></i></span>
        <span class="egg"><i></i></span>
        <span class="egg"><i></i></span>
    </div>
    <div class="times">你还有<i>0次</i>砸蛋机会！</div>
    <div class="my-prize">我的奖品</div>
</div>
<div class="bombBox text">
    <div class="close"></div>
    <div class="boxContent"></div>
</div>
<div style="display:none;width:0;height:0;overflow:hidden">
    <div id="container"></div>
    <img src="./img/half-egg1.png" alt="">
    <img src="./img/half-egg2.png" alt="">
    <img src="./img/half-egg3.png" alt="">
    <img src="./img/hammer.png" alt="">
</div>
<script type="text/javascript">
    (function (doc, win) {
        var docEl = doc.documentElement,
            resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
            recalc = function () {
                var clientWidth = docEl.clientWidth;
                if (!clientWidth) return;
                // 针对uc横竖屏rem html没有重绘的问题
                var style;
                if (style = document.getElementById("forhtml")) {
                    style.parentNode.removeChild(style);
                }
                style = document.createElement("style");
                style.id = "forhtml";
                document.head.appendChild(style);
                style.appendChild(document.createTextNode("html{font-size:" + 20 * (clientWidth / 320) + "px !important;}"));
            };
        recalc();
        document.body.style.visibility = 'visible';
        if (!doc.addEventListener) return;
        win.addEventListener(resizeEvt, recalc, false);
        doc.addEventListener('DOMContentLoaded', recalc, false);
        var a = document.getElementsByTagName('a');
        for (var i = 0; i < a.length; i++) {
            a[i].addEventListener('touchstart', function () {
            }, false);
        }
    })(document, window);
</script>
<script type="text/javascript" charset="utf-8" src="../common/lib/zepto.min.js"></script>
<script type="text/javascript" charset="utf-8" src="../common/lib/zepto-adapter.js"></script>
<script type="text/javascript" charset="utf-8" src="../common/js/bombBox.js"></script>
<script type="text/javascript" charset="utf-8" src="../common/js/modal.js"></script>
<script type="text/javascript" charset="utf-8" src="../common/js/GeoUtils.js"></script>
<script type="text/javascript" charset="utf-8" src="../common/js/utils.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script charset="utf-8" src="../common/js/weixinshare.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        var allPrizes = [], drawReturn = '', lockflag = false;//所有奖品,抽奖返回结果，抽奖锁定
        var isWechat = false,isAPP = false,isFollow = false,isCode=false,isPart=false,activities={};
//        //请求
        judgeSignPass(function(){
            requestAllowed('golden-eggs', function (data) {
                if (allowed.type == 'no-login') {
                    $('.wrap .times').text('你还没有登录哦!');
                } else {
                    $('.wrap .times').html('你还有<i>' + allowed.surplus_times + '</i>次砸蛋机会！');
                }
            });
        });
        requestActInfo('golden-eggs', function (data) {
            $('.date').html('活动时间:' + data.activity.start_at + '&nbsp;至' + data.activity.end_at);
            $('.bombBox.text .boxContent').html(data.activity.description);
            if (data.activity.background_img) {
                $('.wrap').css({
                    'background': 'url(' + data.activity.background_img + ') no-repeat center top',
                    'background-size': '100% auto',
                });
            }
            $('#main').show();
            //===============================
            activities = data.activity;
            isWechat = (window.parameter.ways == 'wechat');//是否开启微信
            isAPP = (activities.publishing.app.is_open == 'on');//是否开启APP
            isFollow = (window.parameter['following'] != 1);//是否关注
            isCode = Boolean(activities.publishing.wechat.qr_code[0]);//是否上传二维码
            if (isWechat) {
                if (isFollow) {
                    isPart = true;
                } else {
                    if (isCode) {
                        var qrCode = QRCode(activities.publishing.wechat.qr_code[0]).open();
                    } else {
                        isPart = true;
                    }
                }
            } else {
                //APP
            }
            //===============================
        });
        requestPrizes(function (data) {
            allPrizes = data;
            var html = '';
            for (var i = 0; i < data.length; i++) {
                html += '<p>' + data[i].name + '</p>';
            }
            $('.item.gift').append(html);
        });
        function openAddress() {
            var addressModal = new Modal({
                prize: drawReturn.prize,
                yesCallback: function () {
                    clear();
                },
                closeCallback: function () {
                    clear();
                }
            }, 'address');
            addressModal.open();
        }

        function clear() {
            $('.egg').removeClass('hammer');
            $('.egg').removeClass('half');
            lockflag = false;
        }

        function openModal(data) {
            if (data.is_winning) {
                var successModal = new Modal({
                    prize: drawReturn.prize,
                    yesCallback: function () {
                        successModal.close();
                        if(data.prize.type_code=='entity'){
                            openAddress();
                        }else{
                            clear();
                            location.href = '/act/common/prizes.html' + location.search;
                        }
                    },
                    closeCallback: function () {
                        clear();
                    }
                }, 'success');
                successModal.open();
            } else {
                var failModal = new Modal({
                    yesCallback: function () {
                        clear();
                        failModal.close();
                    },
                    closeCallback: function () {
                        clear();
                    }
                }, 'fail');
                failModal.open();
            }
        };
        $('.eggs .egg').on('click', function (e) {
            if(!isPart){
                if(isSignPass == -2){
                    if (activities.publishing.app.app_urls[0]) {
                        $.confirm('请下载APP参与活动?',
                            function () {
                                location.href = activities.publishing.app.app_urls[0];
                            },
                            function () {
                            }
                        );
                    } else {
                        $.alert('请下载APP参与活动');
                    }
                    return;
                }
                if(isSignPass == -1) {
                    window.location.href = window.location.href + '&noLogin=true';
                    return;
                }
                if(isSignPass == 0){
                    $.alert('非法请求，请在App中打开');
                    return;
                }
            }
            if(act_info.activity.rules.is_spot&&!isInCircle){
                $.toast('不在范围内哦~~');
                return;
            }
            if (lockflag) return;
            lockflag = !lockflag;
            var $this = $(this);
            function knock(){
                $('.egg').removeClass('hammer');
                $(this).addClass('hammer');
                setTimeout(function () {
                    $('.egg').removeClass('half');
                    $this.addClass('half');
                }, 190);
            }
            knock();
            requestDraw({
                act_id: window.parameter['act_id'],
                uid: window.parameter['uid'],
                type: 'golden-eggs'
            }, function (data) {
                drawReturn = data;
                $('.wrap .times').html('你还有<i>' + data.surplus_times + '</i>次砸蛋机会！');
                setTimeout(function () {
                    openModal(drawReturn);
                }, 500);
            }, function (data) {
                $('.wrap .times').html('你还有<i>' + data.surplus_times + '</i>次砸蛋机会！');
                lockflag = false;
            });
        });
        $('.bombBox.text .close').on('click', function (e) {
            $(this).parents('.bombBox').removeClass('show');
        });
        $('.rule-btn').click(function (e) {
            $('.bombBox.text').addClass('show');
        });
        //跳转-我的奖品
        $('.my-prize').click(function (e) {
            e.preventDefault();
            e.stopPropagation();
            if (!window.parameter['uid']) {
                window.location.href = window.location.href + '&noLogin=true';
            } else {
                location.href = '/act/common/prizes.html' + location.search;
            }
        });
    });
</script>
</body>
</html>